package org.linuxsogood.chapter2.service;

import org.linuxsogood.chapter2.helper.DatabaseHelper;
import org.linuxsogood.chapter2.model.Customer;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by m on 16/3/18.
 */
public class CustomerService {

    /**
     * 查询所有的用户
     * @return 返回库中所有的用户
     */
    public List<Customer> queryAllCustomer() {
        List<Customer> result = new ArrayList<>();
        Connection connection = null;

        try {
            String sql = " SELECT * FROM customer";
            result = DatabaseHelper.queryEntityList(Customer.class, sql);

        } catch (Exception e) {
            //
        } finally {
            DatabaseHelper.closeConnection(connection);
        }
        return result;
    }

    /**
     * 根据用户ID删除用户
     * @param userId 要删除的用户ID
     */
    public int deleteCustomer(long userId) {

        return 1;
    }

    /**
     * 根据ID获取用户信息
     * @param id
     * @return
     */
    public Customer getCustomer(long id) {
        return null;
    }

    public boolean updateCustomer(long id, Map<String, Object> filedMap) {
        return false;
    }

    public boolean createCustomer(Map<String, Object> filedMap) {
        return false;
    }
}
